<template>
  <div>
    <header class="site-header jumbotron">
      <div class="container">
        <div class="row">
          <div class="col-xs-12">
            <h1>请发表对React的评论</h1>
          </div>
        </div>
      </div>
    </header>
    <div class="container">
      <Add :addItem="addItem"/>
      <List :comments="comments" :deleteItem="deleteItem"/>
    </div>
  </div>
</template>

<script>
import Add from './components/Add'
import List from './components/List'

export default {

  name: "App",
  components: {
    Add,
    List
  },
  data() {
    return {
      comments: [
        {
          name: 'BOB',
          content: 'Vue is good'
        },
        {
          name: 'Cat',
          content: 'Vue is gogo'
        },
        {
          name: 'Tom',
          content: 'Vue  is leasy'
        },
      ]
    }
  },
  methods: {
    addItem(comment) {
      this.comments.unshift(comment)
    },
    deleteItem(index){
      this.comments.splice(index,1)
    }
  }
}
</script>

<style scoped>

</style>
